package research.sbookmarking.io;

import java.io.*;
import java.util.zip.GZIPInputStream;

public class ObjectInputStreamFactory extends InputStreamFactory {

	private static ObjectInputStreamFactory anInstance = null;
	
	private ObjectInputStreamFactory () {
		
	}
	
	@Override
	protected InputStream openInputStream (String filename){
		try {
			GZIPInputStream gzip = new GZIPInputStream(super.openInputStream(filename));
			return new ObjectInputStream (gzip);
		}
		catch (IOException e){
			throw new RuntimeException(e);
		}
	}
	
	public static InputStreamFactory getInstance(){
		if (anInstance == null) {
			anInstance = new ObjectInputStreamFactory();
		}
		

		return anInstance;
	}
}
